﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Classes
{
    public partial class FormConfBDWS : Form
    {
        public FormConfBDWS()
        {
            InitializeComponent();
        }

        private void FormConfBDWS_Load(object sender, EventArgs e)
        {
            INIFile ini = new INIFile(Application.StartupPath + "\\Conf.INI");

            tbxServer.Text = ini.IniReadValue("CONFDB", "host");
            tbxDB.Text = ini.IniReadValue("CONFDB", "db");
            tbxUser.Text = ini.IniReadValue("CONFDB", "user");
            if (ini.IniReadValue("CONFDB", "pwd") != "")
                tbxSenha.Text = ini.IniReadValue("CONFDB", "pwd");

            tbxURLWs.Text = ini.IniReadValue("CONFWS", "db");
            tbxUserWs.Text = ini.IniReadValue("CONFWS", "user");
            if (ini.IniReadValue("CONFWS", "pwd") != "")
                tbxPassWs.Text = ini.IniReadValue("CONFWS", "pwd");


        }

        private void btnSalvar_Click(object sender, EventArgs e)
        {
            INIFile ini = new INIFile(Application.StartupPath + "\\Conf.INI");

            ini.IniWriteValue("CONFDB", "host", tbxServer.Text);
            ini.IniWriteValue("CONFDB", "db", tbxDB.Text);
            ini.IniWriteValue("CONFDB", "user", tbxUser.Text);
            ini.IniWriteValue("CONFDB", "pwd", tbxSenha.Text); //StringCipher.Encrypt("12345678", tbxSenha.Text));

            ini.IniWriteValue("CONFWS", "host", tbxURLWs.Text);
            ini.IniWriteValue("CONFWS", "db", tbxUserWs.Text);
            ini.IniWriteValue("CONFWS", "user", tbxPassWs.Text);



            this.Close();
        }




    }
}
